package com.kstudio.videocapture.util;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;

public class KAnimation extends AnimationSet {
    private final KLog log = new KLog("KAnimation");

    public static final int SHINY = 0x0001;

    private View kView;

    public KAnimation(boolean shareInterpolator) {
        super(shareInterpolator);
    }

    public KAnimation(boolean shareInterpolator, int mode, View view) {
        this(shareInterpolator);
        kView = null;

        switch (mode) {
            case SHINY : {
                kView = view;
                Animation a1 = new AlphaAnimation(0.0f, 1.0f);
                a1.setDuration(1000);
                this.addAnimation(a1);

                Animation a2 = new AlphaAnimation(1.0f, 0.0f);
                a2.setDuration(1000);
                this.addAnimation(a2);

                this.setAnimationListener(new AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                        log.i("onAnimationStart");
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        log.i("onAnimationEnd");
                        kView.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                        log.i("onAnimationRepeat");
                    }
                });
                kView.setAnimation(this);
            }
            break;
        }

    }



}
